package com.qtjf.qtmoneyservice.activity;

import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.github.jdsjlzx.recyclerview.LRecyclerView;
import com.github.jdsjlzx.recyclerview.LRecyclerViewAdapter;
import com.qtjf.qtmoneyservice.R;
import com.qtjf.qtmoneyservice.adapter.XiTongRecyclerAdapter;
import com.qtjf.qtmoneyservice.adapter.YouHuiRecyclerAdapter;

import java.util.ArrayList;
import java.util.List;

public class YouHuiActivity extends BaseActivity {
    ImageView mBack;

    LRecyclerView homeRecycler;
    List<String> lists;
    YouHuiRecyclerAdapter adapter;
    LRecyclerViewAdapter lRecyclerViewAdapter;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_you_hui);

        super.setTranslucent();

        initView();
        initData();
        initEvent();
    }

    private void initView() {
        mBack= (ImageView) findViewById(R.id.back_bt);
        homeRecycler= (LRecyclerView)findViewById(R.id.recycler_view);
        homeRecycler.setPullRefreshEnabled(false);
    }

    private void initData() {
        lists = new ArrayList<String>();
        for (int i = 0; i < 5; i++) {
            lists.add("" + i);
        }

        if (lists != null && lists.size() > 0) {
            if (adapter == null) {
                adapter = new  YouHuiRecyclerAdapter(lists, this);
                lRecyclerViewAdapter = new LRecyclerViewAdapter(adapter);
                homeRecycler.setAdapter(lRecyclerViewAdapter);
                homeRecycler.setLayoutManager(new StaggeredGridLayoutManager(1, StaggeredGridLayoutManager.VERTICAL));
                //  Toast.makeText(getContext(),"1",Toast.LENGTH_SHORT).show();
            } else {
                lRecyclerViewAdapter.notifyDataSetChanged();
                // Toast.makeText(getContext(),"2",Toast.LENGTH_SHORT).show();
                homeRecycler.refreshComplete();
            }
        }
    }

    private void initEvent() {
        mBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                YouHuiActivity.this.finish();
            }
        });

    }
}
